clear all;close all;clc
% Subject ID: 63, 64, 68, 69, 70, 72, 73, 74, 75, 76, 77, 78, 79, 80

Sessions_all=1:20;
Subjects = {'63', '64', '68', '69', '70', '72', '73', '74', '75', '76', '77', '78', '79', '80','81','82'};
fingers = 'abcde';
finger_names = {'Thumb';'Index';'Middle';'Ring';'Pinky'};
f_low = 0.1;
f_high = 30;
FS = 198.5;
[b,a]=butter(3,[f_low f_high]./(FS./2));

for isubject = 1:length(Subjects)
    Sub = Subjects{isubject}   
    file_save = ['Save_EMG_NN_result\' Sub '_CM.mat'];
    load(file_save);   
    PCall(isubject) = PC;
    pci(isubject) = f_confid_I(length(Sessions_all)*20*5,PCall(isubject)/100,0.05);   
end

% ============ Plot Overall Accuracy for Different Subjects ==============
f3 = figure('position',[100 100 600 300]);
s=bar((1:length(Subjects)),PCall,0.8);
set(s,'facecolor',[0.5 0.5 0.5])
hold on;
ylim([0 100])
errorbar((1:length(Subjects)),PCall,pci*100,'.k');
plot([0 length(Subjects)+1],[20 20],'k');
set(gca,'xtick',1:16);
ylim([0 100]);
xlabel('Subject');
ylabel('Accuracy (%)');
title('EMG Accuracy for All Subjects')
box off;
% =========== export figure ============
exportgraphics(f3,'Figure7_EMG.png','Resolution',300);

save EMG_PC_resultall PCall